<?php
/**
 * Created by PhpStorm.
 * User: liyu
 * Date: 2018/4/25
 * Time: 下午4:41
 */

namespace app\api\controller\v1;


use app\api\service\OrgService;
use app\api\validate\OrgValidate;
use think\Request;

class Org extends UserAuth
{
    public function create()
    {
        (new OrgValidate())->goCheck('add');
        $data = Request::instance()->only(['name','parent_id']);
        (new OrgService())->create($this->guid,$data);
        return $this->showJsonReturnCode();
    }

    public function update()
    {
        (new OrgValidate())->goCheck('update');
        $where = Request::instance()->only(['id']);
        $data = Request::instance()->only(['name','parent_id']);
        (new OrgService())->update($this->guid,$where,$data);
        return $this->showJsonReturnCode();
    }

    public function getList()
    {
        $where = Request::instance()->only(['name']);
        $result = (new OrgService())->getOrgInfoListByMap($where);
        return $this->showJsonReturnCode($result);
    }
}